package com.example.javabase.multithread.readwritelock;

/**
 * @author He Changjie on 2021/7/11
 */
public class WriteTask implements Runnable {
    private RWDictionary dictionary;

    public WriteTask(RWDictionary dictionary) {
        this.dictionary = dictionary;
    }

    @Override
    public void run() {
        int i = 0;
        while (true){
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            String name = Thread.currentThread().getName();
            dictionary.put("RW key", name + "-----" + i++);
        }
    }
}
